<template>
  <div class="purchase-info innerPageTable-out-flex">
    <search-form
      :form-data="formData"
      @search="searchHandle"
      @reset="resetHandle"
      :label-width="170"
    ></search-form>

    <InnerPageTable ref="listTable" :config="pageTableConfig">
      <div slot="table-bar">
        <Button v-show="false" @click.native="selectUpload(true, 'supplier/update')">全部上报</Button>
        <Button v-show="false" @click.native="selectUpload(false, 'supplier/update')" :disabled="btnDisabled">勾选上报</Button>
        <Button @click.native="downHandle('03')" v-if='showCurrentBtn'>模板下载</Button>
        <Button @click.native="exportHandle('supplier/export')" :disabled="btnDisabled">导出</Button>
        <Button @click.native="importHandle" v-if='showCurrentBtn'>导入</Button>
        <Button @click.native="readWareHandle" :disabled="!selectData.length" v-if='currentRole.split(",").includes("1")'>已阅警告</Button>
        <input type="file" ref="selectFile" style="display:none" @change="importData($event, 'supplier/import')" />
        <Button v-show="false"></Button>
      </div>
    </InnerPageTable>
  </div>
</template>
<script>
import SearchForm from "@/components/common/SearchForm"
import {configForm, generateColumns, detailField} from './js/offer-constant'
import { superviseInfoAPI } from "@api/superviseInfo";
import detailPage from "@/components/detailInfo";
import { mixin } from "@/views/superviseInfo/mix/mixin";
import { stateHandleMix } from "@/views/superviseInfo/mix/stateHandleMix";

export default {
  name: 'offer-supplier',
  components: {
    searchForm: SearchForm
  },
  mixins: [mixin, stateHandleMix],
  computed: {
    searchData() {
      return configForm.bind(this)()
    }
  },
  data () {
    return {
      pageTableConfig: {
        loadDataFn: this.getTableList,
        columns: generateColumns.bind(this)(),
        initParam: {
          "crsrm_bidding_id": "",
          "crsrm_bidding_name": "",
          "crsrm_data_source": "",
          "crsrm_purchaser_sbu": "",
          "crsrm_state": "",
          "crsrm_supplier_name": "",
          "crsrm_supplier_social_credit": "",
          "endDate": 0,
          "push_state": "",
          "resultState": [],
          "startDate": 0
        },
        autoFirst: true,
        selectionAreaItem: { key: "id", title: "userName" },
        allSelection: [],
        onSelectionChange: this.selectHandle,
      }
    }
  },
  methods: {
    getTableList(tableObj) {
      let { responseProcess, param, initParam } = tableObj;
      const params = {
        ...initParam,
        ...param
      }
      superviseInfoAPI.offerList(params).then(res => {
        responseProcess(res.data);
      })
    },
    detailHandle(id) {
      let detailInfo = {}
      this.$Spin.show()
      superviseInfoAPI.offerDetail({ id: id }).then(res => {
        detailInfo = res.data
        this.$Spin.hide()
        new this.$sidelipPage(detailPage, { props: { detailInfo, detailField, title: '报价供应商详情', listId: id }, isNav: false });
      })
    },
  }
}
</script>

